<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			window.onload = function()
			{
				let p = document.querySelector('p');
				let Add = document.querySelector('#Add');
				let Sub = document.querySelector('#Sub');
				let val = 0;
				
				Add.onclick = function()
				{
					val += 1;
					p.innerHTML = `您购买了${val}件商品`;
				}
				
				Sub.onclick = function()
				{
					if(val != 0)
					{
						val -= 1;
						p.innerHTML = `您购买了${val}件商品`;
					}
				}
			}
		</script>
	</head>
	<body>
		<p>您购买了0件商品</p>
		<button id="Add">+</button>
		<button id="Sub">-</button>
	</body>
</html>